package tt.com.financialmanagement.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import tt.com.common.model.YxCommonPurchase;
import tt.com.common.model.YxCommonPurchaseServe;
import tt.com.financialmanagement.mapper.YxCommonPurchaseServeMapper;

import tt.com.financialmanagement.service.YxCommonPurchaseServeService;

import java.util.List;

@Service
public class YxCommonPurchaseServeServiceImpl extends ServiceImpl<YxCommonPurchaseServeMapper, YxCommonPurchaseServe>implements YxCommonPurchaseServeService {

    @Override
    public ResponseEntity selectByWuID(YxCommonPurchase yxCommonPurchase) {
        //判断该物品是否有采购信息
        QueryWrapper<YxCommonPurchaseServe> wrapper = new QueryWrapper<>();
        wrapper.eq("data_status",0);
        wrapper.eq("organ_id",yxCommonPurchase.getPurchaseNo());
        List<YxCommonPurchaseServe> yxCommonPurchaseServes = baseMapper.selectList(wrapper);
        if (yxCommonPurchaseServes.size()<0){
            return new ResponseEntity("该采购单没有详细信息", HttpStatus.INTERNAL_SERVER_ERROR);
        }
        return new ResponseEntity(yxCommonPurchaseServes,HttpStatus.OK);
    }
}
